package com.wing.user.controller.admin;

import com.wing.common.exception.BusinessException;
import com.wing.common.utils.JsonResult;
import com.wing.user.service.CloudServerService;
import com.wing.user.service.FaceRecognitionService;
import com.wing.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 云服务器
 */

@Validated
@Api(value = "云服务器")
@RestController("cloudServerController")
@RequestMapping("/user/admin/cloudServer")
@RequiredArgsConstructor
public class CloudServerController {

    private final CloudServerService cloudServerService;

    @ApiOperation(value = "创建实例")
    @GetMapping("/runInstances")
    public JsonResult runInstances() {
        try {
            return JsonResult.success(cloudServerService.runInstances());
        } catch (BusinessException e) {
            return JsonResult.fail(e.getCode(), e.getMessage());
        } catch (Exception e) {
            return JsonResult.fail(e.getMessage());
        }
    }

}
